package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单赠送优惠卷信息
 * @author xiechenhui
 * @version 2.0.0
 * @date 2021-11-01
 */
@Data
@Table(schema = "public", name = "ord_give_coupon", indexes = {@Index(name = "ord_give_coupon_order_id_idx", columnList = "order_id")})
@Entity
public class OrderGiveCouponDO implements Serializable {
    private static final long serialVersionUID = 4414467570423040994L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_give_coupon_seq")
    @SequenceGenerator(sequenceName = "ord_give_coupon_seq", name = "ord_give_coupon_seq", allocationSize = 1)
    private Long id;

    /**
     * 一对一双向关联订单
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="order_id", referencedColumnName="id")
    private OrderDO order;

    /**
     * 赠品id
     */
    @Column
    private Long giveId;

    /**
     * 商品SkuId
     */
    @Column
    private Long skuId;

    /**
     * 名称
     */
    @Column
    private String name;

    /**
     * 商品id
     */
    @Column
    private Long productId;

    /**
     * 赠送数量
     */
    @Column
    private BigDecimal quantity;

    /**
     * 品类
     */
    @Column
    private String category;

    /**
     * 品牌
     */
    @Column
    private String brand;

    /**
     * 单位
     */
    @Column
    private String unit;
}
